package com.minimalist.common.entity.basic.po;

import com.mybatisflex.annotation.Table;

import java.io.Serial;
import java.io.Serializable;

/**
 * 用户与角色关联表 1用户-N角色 实体类。
 *
 * @author 小太阳
 * @since 2024-10-18
 */
@Table(value = "m_user_role")
public class MUserRole implements Serializable{

    public MUserRole() {
    }

    public MUserRole(Long userId, Long roleId) {
        this.userId = userId;
        this.roleId = roleId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MUserRole mUserRole = (MUserRole) o;
        if (userId != null ? !userId.equals(mUserRole.userId) : mUserRole.userId != null) return false;
        return roleId != null ? roleId.equals(mUserRole.roleId) : mUserRole.roleId == null;
    }

    @Override
    public int hashCode() {
        int result = userId != null ? userId.hashCode() : 0;
        result = 31 * result + (roleId != null ? roleId.hashCode() : 0);
        return result;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private Long userId;
        private Long roleId;

        Builder() {
        }

        public Builder userId(Long userId) {
            this.userId = userId;
            return this;
        }

        public Builder roleId(Long roleId) {
            this.roleId = roleId;
            return this;
        }

        public MUserRole build() {
            return new MUserRole(userId, roleId);
        }
    }

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 角色ID
     */
    private Long roleId;

}
